function ajax(method, url, dataObj, callback) {
	//1.创建xhr
	var xhr = new XMLHttpRequest();
	xhr.timeout = 5000;
	//2.创建url
	if(method.toUpperCase() == "GET") {
		if(!url.includes("?")) {
			url = url + "?";
		}
		//3.拼接请求参数
		if(dataObj && typeof dataObj == "object") {
			for(var key in dataObj) {
				url += `${key}=${dataObj[key]}&`
			}
		}
		url = url.slice(0, -1);
	}

	xhr.open(method, url);
	xhr.send(dataObj);
	xhr.addEventListener('readystatechange', function() {
		if(xhr.readyState == 4) {
			if(xhr.status == 200) {
				callback(xhr.response);
			}
		}
	})

}